package main.kotlin.solution

import java.util.*

class MaxDepth {

    class TreeNode(var `val`: Int) {
        var left: TreeNode? = null
        var right: TreeNode? = null
    }

    fun maxDepth(root: TreeNode?): Int {
        var depth = 0
        var queue = LinkedList<TreeNode?>()
        queue.add(root)
        println(queue.size)
        while(!queue.isEmpty()){
            depth++
            for(i in 0 until queue.size){
                var node = queue.poll()
                if(node == null){
                    continue
                }
                queue.add(node.left)
                queue.add(node.right)
            }
        }
        return depth
    }

}